package com.webank.contracts;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Future;
import org.bcos.channel.client.TransactionSucCallback;
import org.bcos.web3j.abi.EventEncoder;
import org.bcos.web3j.abi.EventValues;
import org.bcos.web3j.abi.FunctionEncoder;
import org.bcos.web3j.abi.TypeReference;
import org.bcos.web3j.abi.datatypes.Address;
import org.bcos.web3j.abi.datatypes.Event;
import org.bcos.web3j.abi.datatypes.Function;
import org.bcos.web3j.abi.datatypes.Type;
import org.bcos.web3j.abi.datatypes.Utf8String;
import org.bcos.web3j.abi.datatypes.generated.Uint16;
import org.bcos.web3j.abi.datatypes.generated.Uint32;
import org.bcos.web3j.abi.datatypes.generated.Uint64;
import org.bcos.web3j.abi.datatypes.generated.Uint8;
import org.bcos.web3j.crypto.Credentials;
import org.bcos.web3j.protocol.Web3j;
import org.bcos.web3j.protocol.core.DefaultBlockParameter;
import org.bcos.web3j.protocol.core.methods.request.EthFilter;
import org.bcos.web3j.protocol.core.methods.response.Log;
import org.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
import org.bcos.web3j.tx.Contract;
import org.bcos.web3j.tx.TransactionManager;
import rx.Observable;
import rx.functions.Func1;

/**
 * Auto generated code.<br>
 * <strong>Do not modify!</strong><br>
 * Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>, or {@link org.bcos.web3j.codegen.SolidityFunctionWrapperGenerator} to update.
 *
 * <p>Generated with web3j version none.
 */
public final class Exam extends Contract {
    private static String BINARY = "6060604052341561000c57fe5b604051610b3f380380610b3f833981016040528080519060200190919080519060200190919080519060200190919080519060200190919080519060200190919080519060200190919080518201919060200180518201919050505b87600060006101000a81548163ffffffff021916908363ffffffff16021790555086600060046101000a81548163ffffffff021916908363ffffffff16021790555085600060086101000a81548163ffffffff021916908363ffffffff160217905550846000600c6101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555083600060146101000a81548161ffff021916908361ffff16021790555082600060166101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555032600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006000601e6101000a81548160ff021916908360ff16021790555081600290805190602001906101ad929190610498565b5080600390805190602001906101c4929190610498565b507ff08b7b4518a4956f6b669386eba9106d818b76fa46cb805417489c8ef2929b17600060009054906101000a900463ffffffff16600060049054906101000a900463ffffffff16600060089054906101000a900463ffffffff166000600c9054906101000a900467ffffffffffffffff16600060149054906101000a900461ffff16600060169054906101000a900467ffffffffffffffff1660026003600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1630604051808b63ffffffff1663ffffffff1681526020018a63ffffffff1663ffffffff1681526020018963ffffffff1663ffffffff1681526020018867ffffffffffffffff1667ffffffffffffffff1681526020018761ffff1661ffff1681526020018667ffffffffffffffff1667ffffffffffffffff16815260200180602001806020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381038352878181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156103ef5780601f106103c4576101008083540402835291602001916103ef565b820191906000526020600020905b8154815290600101906020018083116103d257829003601f168201915b50508381038252868181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156104725780601f1061044757610100808354040283529160200191610472565b820191906000526020600020905b81548152906001019060200180831161045557829003601f168201915b50509c5050505050505050505050505060405180910390a15b505050505050505061053d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106104d957805160ff1916838001178555610507565b82800160010185558215610507579182015b828111156105065782518255916020019190600101906104eb565b5b5090506105149190610518565b5090565b61053a91905b8082111561053657600081600090555060010161051e565b5090565b90565b6105f38061054c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806329b5ddb7146100465780632e49d78b14610217575bfe5b341561004e57fe5b610056610252565b604051808b63ffffffff1663ffffffff1681526020018a63ffffffff1663ffffffff1681526020018963ffffffff1663ffffffff1681526020018867ffffffffffffffff1667ffffffffffffffff1681526020018761ffff1661ffff1681526020018667ffffffffffffffff1667ffffffffffffffff1681526020018560ff1660ff16815260200180602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183810383528681815181526020019150805190602001908083836000831461015f575b80518252602083111561015f5760208201915060208101905060208303925061013b565b505050905090810190601f16801561018b5780820380516001836020036101000a031916815260200191505b508381038252858181518152602001915080519060200190808383600083146101d3575b8051825260208311156101d3576020820191506020810190506020830392506101af565b505050905090810190601f1680156101ff5780820380516001836020036101000a031916815260200191505b509c5050505050505050505050505060405180910390f35b341561021f57fe5b610238600480803560ff1690602001909190505061047a565b604051808215151515815260200191505060405180910390f35b60006000600060006000600060006102686105b3565b6102706105b3565b6000600060009054906101000a900463ffffffff16600060049054906101000a900463ffffffff16600060089054906101000a900463ffffffff166000600c9054906101000a900467ffffffffffffffff16600060149054906101000a900461ffff16600060169054906101000a900467ffffffffffffffff166000601e9054906101000a900460ff1660026003600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103b65780601f1061038b576101008083540402835291602001916103b6565b820191906000526020600020905b81548152906001019060200180831161039957829003601f168201915b50505050509250818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104525780601f1061042757610100808354040283529160200191610452565b820191906000526020600020905b81548152906001019060200180831161043557829003601f168201915b5050505050915099509950995099509950995099509950995099505b90919293949596979899565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff161415156104d95760006000fd5b816000601e6101000a81548160ff021916908360ff1602179055507fed5986ab6e22aebd210b902b04bb713545b01a3c14c002b51296cd3720f094996000601e9054906101000a900460ff163230604051808460ff1660ff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001935050505060405180910390a1600190505b5b919050565b6020604051908101604052806000815250905600a165627a7a723058204d72e9df739c4c5843da68075fa8ec43f14fcda95274482f6f57f2783a6b5d8a0029";

    public static final String ABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"getExam\",\"outputs\":[{\"name\":\"\",\"type\":\"uint32\"},{\"name\":\"\",\"type\":\"uint32\"},{\"name\":\"\",\"type\":\"uint32\"},{\"name\":\"\",\"type\":\"uint64\"},{\"name\":\"\",\"type\":\"uint16\"},{\"name\":\"\",\"type\":\"uint64\"},{\"name\":\"\",\"type\":\"uint8\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"status\",\"type\":\"uint8\"}],\"name\":\"setStatus\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"ExamId\",\"type\":\"uint32\"},{\"name\":\"crewId\",\"type\":\"uint32\"},{\"name\":\"eventId\",\"type\":\"uint32\"},{\"name\":\"examDate\",\"type\":\"uint64\"},{\"name\":\"term\",\"type\":\"uint16\"},{\"name\":\"createTime\",\"type\":\"uint64\"},{\"name\":\"reserve1\",\"type\":\"string\"},{\"name\":\"reserve2\",\"type\":\"string\"}],\"payable\":false,\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"ExamId\",\"type\":\"uint32\"},{\"indexed\":false,\"name\":\"crewId\",\"type\":\"uint32\"},{\"indexed\":false,\"name\":\"eventId\",\"type\":\"uint32\"},{\"indexed\":false,\"name\":\"examDate\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"term\",\"type\":\"uint16\"},{\"indexed\":false,\"name\":\"createTime\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"reserve1\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"reserve2\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"newExamEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"status\",\"type\":\"uint8\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setStatusEvent\",\"type\":\"event\"}]";

    private Exam(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, Boolean isInitByName) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit, isInitByName);
    }

    private Exam(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, Boolean isInitByName) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit, isInitByName);
    }

    private Exam(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit, false);
    }

    private Exam(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit, false);
    }

    public static List<NewExamEventEventResponse> getNewExamEventEvents(TransactionReceipt transactionReceipt) {
        final Event event = new Event("newExamEvent", 
                Arrays.<TypeReference<?>>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint64>() {}, new TypeReference<Uint16>() {}, new TypeReference<Uint64>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
        List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
        ArrayList<NewExamEventEventResponse> responses = new ArrayList<NewExamEventEventResponse>(valueList.size());
        for (EventValues eventValues : valueList) {
            NewExamEventEventResponse typedResponse = new NewExamEventEventResponse();
            typedResponse.ExamId = (Uint32) eventValues.getNonIndexedValues().get(0);
            typedResponse.crewId = (Uint32) eventValues.getNonIndexedValues().get(1);
            typedResponse.eventId = (Uint32) eventValues.getNonIndexedValues().get(2);
            typedResponse.examDate = (Uint64) eventValues.getNonIndexedValues().get(3);
            typedResponse.term = (Uint16) eventValues.getNonIndexedValues().get(4);
            typedResponse.createTime = (Uint64) eventValues.getNonIndexedValues().get(5);
            typedResponse.reserve1 = (Utf8String) eventValues.getNonIndexedValues().get(6);
            typedResponse.reserve2 = (Utf8String) eventValues.getNonIndexedValues().get(7);
            typedResponse.owner = (Address) eventValues.getNonIndexedValues().get(8);
            typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(9);
            responses.add(typedResponse);
        }
        return responses;
    }

    public Observable<NewExamEventEventResponse> newExamEventEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        final Event event = new Event("newExamEvent", 
                Arrays.<TypeReference<?>>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint64>() {}, new TypeReference<Uint16>() {}, new TypeReference<Uint64>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(event));
        return web3j.ethLogObservable(filter).map(new Func1<Log, NewExamEventEventResponse>() {
            @Override
            public NewExamEventEventResponse call(Log log) {
                EventValues eventValues = extractEventParameters(event, log);
                NewExamEventEventResponse typedResponse = new NewExamEventEventResponse();
                typedResponse.ExamId = (Uint32) eventValues.getNonIndexedValues().get(0);
                typedResponse.crewId = (Uint32) eventValues.getNonIndexedValues().get(1);
                typedResponse.eventId = (Uint32) eventValues.getNonIndexedValues().get(2);
                typedResponse.examDate = (Uint64) eventValues.getNonIndexedValues().get(3);
                typedResponse.term = (Uint16) eventValues.getNonIndexedValues().get(4);
                typedResponse.createTime = (Uint64) eventValues.getNonIndexedValues().get(5);
                typedResponse.reserve1 = (Utf8String) eventValues.getNonIndexedValues().get(6);
                typedResponse.reserve2 = (Utf8String) eventValues.getNonIndexedValues().get(7);
                typedResponse.owner = (Address) eventValues.getNonIndexedValues().get(8);
                typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(9);
                return typedResponse;
            }
        });
    }

    public static List<SetStatusEventEventResponse> getSetStatusEventEvents(TransactionReceipt transactionReceipt) {
        final Event event = new Event("setStatusEvent", 
                Arrays.<TypeReference<?>>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint8>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
        List<EventValues> valueList = extractEventParameters(event, transactionReceipt);
        ArrayList<SetStatusEventEventResponse> responses = new ArrayList<SetStatusEventEventResponse>(valueList.size());
        for (EventValues eventValues : valueList) {
            SetStatusEventEventResponse typedResponse = new SetStatusEventEventResponse();
            typedResponse.status = (Uint8) eventValues.getNonIndexedValues().get(0);
            typedResponse.owner = (Address) eventValues.getNonIndexedValues().get(1);
            typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(2);
            responses.add(typedResponse);
        }
        return responses;
    }

    public Observable<SetStatusEventEventResponse> setStatusEventEventObservable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        final Event event = new Event("setStatusEvent", 
                Arrays.<TypeReference<?>>asList(),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint8>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(event));
        return web3j.ethLogObservable(filter).map(new Func1<Log, SetStatusEventEventResponse>() {
            @Override
            public SetStatusEventEventResponse call(Log log) {
                EventValues eventValues = extractEventParameters(event, log);
                SetStatusEventEventResponse typedResponse = new SetStatusEventEventResponse();
                typedResponse.status = (Uint8) eventValues.getNonIndexedValues().get(0);
                typedResponse.owner = (Address) eventValues.getNonIndexedValues().get(1);
                typedResponse.addr = (Address) eventValues.getNonIndexedValues().get(2);
                return typedResponse;
            }
        });
    }

    public Future<List<Type>> getExam() {
        Function function = new Function("getExam", 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint64>() {}, new TypeReference<Uint16>() {}, new TypeReference<Uint64>() {}, new TypeReference<Uint8>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}));
        return executeCallMultipleValueReturnAsync(function);
    }

    public Future<TransactionReceipt> setStatus(Uint8 status) {
        Function function = new Function("setStatus", Arrays.<Type>asList(status), Collections.<TypeReference<?>>emptyList());
        return executeTransactionAsync(function);
    }

    public void setStatus(Uint8 status, TransactionSucCallback callback) {
        Function function = new Function("setStatus", Arrays.<Type>asList(status), Collections.<TypeReference<?>>emptyList());
        executeTransactionAsync(function, callback);
    }

    public static Future<Exam> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Uint32 ExamId, Uint32 crewId, Uint32 eventId, Uint64 examDate, Uint16 term, Uint64 createTime, Utf8String reserve1, Utf8String reserve2) {
        String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(ExamId, crewId, eventId, examDate, term, createTime, reserve1, reserve2));
        return deployAsync(Exam.class, web3j, credentials, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
    }

    public static Future<Exam> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, BigInteger initialWeiValue, Uint32 ExamId, Uint32 crewId, Uint32 eventId, Uint64 examDate, Uint16 term, Uint64 createTime, Utf8String reserve1, Utf8String reserve2) {
        String encodedConstructor = FunctionEncoder.encodeConstructor(Arrays.<Type>asList(ExamId, crewId, eventId, examDate, term, createTime, reserve1, reserve2));
        return deployAsync(Exam.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, encodedConstructor, initialWeiValue);
    }

    public static Exam load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new Exam(contractAddress, web3j, credentials, gasPrice, gasLimit, false);
    }

    public static Exam load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new Exam(contractAddress, web3j, transactionManager, gasPrice, gasLimit, false);
    }

    public static Exam loadByName(String contractName, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new Exam(contractName, web3j, credentials, gasPrice, gasLimit, true);
    }

    public static Exam loadByName(String contractName, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new Exam(contractName, web3j, transactionManager, gasPrice, gasLimit, true);
    }

    public static class NewExamEventEventResponse {
        public Uint32 ExamId;

        public Uint32 crewId;

        public Uint32 eventId;

        public Uint64 examDate;

        public Uint16 term;

        public Uint64 createTime;

        public Utf8String reserve1;

        public Utf8String reserve2;

        public Address owner;

        public Address addr;
    }

    public static class SetStatusEventEventResponse {
        public Uint8 status;

        public Address owner;

        public Address addr;
    }
}
